/**
 * @file field
 * @author fanxueliang@qq.com
 */
import type {AudioUploadSpecItem, AudioUploaderField} from '../interface';
import {getBasicField} from '../util';

export function createAudioUploaderField(spec: AudioUploadSpecItem, showIndex: number, path: string) {
    if (spec.rules) {
        spec.rules.audioUrl = true;
    } else {
        spec.rules = {
            audioUrl: true
        };
    }
    const basicField = getBasicField(spec, path, showIndex);
    return {
        ...basicField,
        type: 'STRING',
        isLeaf: true,
        spec,
        component: 'AudioUploader'
    } as AudioUploaderField;
}
